/*
 * 修改销售渠道交易
 * 参数   交易码：trancode=15123
 * 
 */

package org.ccams.tran;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.ccams.domain.TSalesChannel;
/**
 * 修改销售渠道交易
 * @author liuguangshuai@gmail.com
 * @系统名称：定制化辅助生成制造系统
 * @时间：Sep 12, 2008
 */
public class Tran15123 extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String meaning = (String) request.getParameter("meaning");
		String description = (String) request.getParameter("description");
		String loanInvOrg1 = (String) request.getParameter("loanInvOrg1");
		String loanSubinventory1 = (String) request.getParameter("loanSubinventory1");
		String loanInvOrg2 = (String) request.getParameter("loanInvOrg2");
		String loanSubinventory2 = (String) request.getParameter("loanSubinventory2");
		Integer salesZoneId = Integer.parseInt(request.getParameter("salesZoneId"));
		Long salesChannelCode = Long.parseLong(request.getParameter("id"));
		meaning = (meaning != null) ? meaning : "";
		description = (description != null) ? description : "";
		loanInvOrg1 = (loanInvOrg1 != null) ? loanInvOrg1 : "";
		loanSubinventory1 = (loanSubinventory1 != null) ? loanSubinventory1 : "";
		loanInvOrg2 = (loanInvOrg2 != null) ? loanInvOrg2 : "";
		loanSubinventory2 = (loanSubinventory2 != null) ? loanSubinventory2 : "";
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		boolean success = false;
		String message = "";
		TSalesChannel t = new TSalesChannel();
		t.setDescription(description);
		t.setMeaning(meaning);
		t.setLoanInvOrg1(loanInvOrg1);
		t.setLoanInvOrg2(loanInvOrg2);
		t.setLoanSubinventory1(loanSubinventory1);
		t.setLoanSubinventory2(loanSubinventory2);
		t.setSalesZoneId(salesZoneId);
		t.setSalesChannelCode(salesChannelCode);
		int i = getCcamsService().getTsaleschannelDao().updateByPrimaryKeySelective(t);
		if (i == 1) {
			success = true;
			message = "销售渠道修改成功";
		} else {
			success = false;
			message = "销售渠道修改失败";
		}
		jsonMap.put("success", success);
		jsonMap.put("message", message);
		json.putAll(jsonMap);
	}
}
